// pages/my_bm/my_bm.js
const app = getApp();
var router = require("../../router.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    page: 0,
    info: false,  
  },

  /**
   * 生命周期函数--监听页面加载
   */ 
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    app.isLogin();
    this.getInfo();
  },
  xianqing: function(e){
    var expand_id = e.currentTarget.dataset.id
    var expand_type = e.currentTarget.dataset.type
    if (expand_type == 1){
      app.navTo('../home_new/home_detail?id=' + expand_id + '&types=' + expand_type)
    } else if (expand_type == 2) {
      app.navTo('../home_new/home_detail?id=' + expand_id + '&types=' + expand_type)
    } else if (expand_type == 3){
      app.navTo('../person_active_detail/person_active_detail?id=' + expand_id + '&types=' + expand_type)
    }
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getInfo();
  },

  getInfo: function () {
    if (wx.getStorageSync('userInfo')) {
      var that = this;
      app.request({
        url: router.expand.mys,
        method: "POST",
        data: {
          userId: wx.getStorageSync('userInfo').id,
          page: that.data.page,
        },
        success: function (data) { 
          console.log('resrse',data)
          if (data.status == true) {
            if (data.list.length > 0) {
              for (var i = 0; i < data.list.length; i++) {
                var obj = {};
                obj = data.list[i];
                that.data.list.push(obj);
              }
              that.setData({
                list: that.data.list,
                page: that.data.page + 1
              });
            } else {
              that.setData({
                info: true,
              });
            }
          } else {
            wx.showToast({
              title: '获取信息失败',
              icon: 'none',
              mask: true,
              duration: 2000
            });
          }
        }
      })
    }
  }
})